package com.stox.client.ui.javafx.chartingy.event.listener;

import com.stox.client.ui.core.event.ApplicationEvent;
import com.stox.client.ui.core.event.ScripSelectionEvent;
import com.stox.client.ui.core.event.SmartApplicationListener;
import com.stox.client.ui.javafx.chartingy.view.ChartingViewDisplayHelper;

public class ChartingEventListener implements SmartApplicationListener{
	
	public static final ChartingEventListener INSTANCE = new ChartingEventListener();
	
	private ChartingEventListener() {

	}
	
	@Override
	public void onApplicationEvent(ApplicationEvent event) {
		ScripSelectionEvent scripSelectionEvent = (ScripSelectionEvent)event;
		ChartingViewDisplayHelper.INSTANCE.single(scripSelectionEvent.getNavigable());
	}

	@Override
	public int getOrder() {
		return 0;
	}

	@Override
	public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
		return ScripSelectionEvent.class.isAssignableFrom(eventType);
	}

	@Override
	public boolean supportsSourceType(Class<?> sourceType) {
		return true;
	}

}
